<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="com.etc.controller.*" %>
<%@page import="com.etc.entity.Message" %>
<%@page import="com.etc.util.*" %>
<%@page import="com.etc.dao.*" %>
<%@page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" type="text/css" href="css/showmessage.css">
<body>
<ul>
<%
PageTool pageTool = (PageTool)request.getAttribute("listMessage");
  String search= (String)request.getSession().getAttribute("search");
List<Message> list=pageTool.getList();
/*   if(search!=null){
	  list = (List<Message>)request.getSession().getAttribute("listMessage"); 
  } */
for(int i=0;i<list.size();i++){
	 request.setAttribute("message", list.get(i)); 
%>

<li><a href='AnsMessageServlet?am=detail&id=${message.id }'><p class='title'>${message.title}&nbsp;<font class='date'>${message.date }</font><font class='username'>&nbsp;&nbsp;&nbsp;${message.username }</font></p></a></li>
<%
}
%>
</ul>
<div style="height:50px;line-height:50px;text-align:center;">
 <%
 int pageindex = pageTool.getPageIndex();
 int pagetotal = pageTool.getTotalPage();
 
 
 if(pageindex>1){
 %>
	<a href="ListMessageServlet?pageIndex=1">首页</a>
	<a href="ListMessageServlet?pageIndex=<%=pageindex-1%>">上一页</a>
	<%
 }
	%>
	<%
	if(pageindex<pagetotal){
	%>
	<a href="ListMessageServlet?pageIndex=<%=pageindex+1%>">下一页</a>
	<%
	}
	%>
	<%
	if(pageindex!=pagetotal){
	%>
	<a href="ListMessageServlet?pageIndex=<%=pagetotal%>">末页</a>
	  <%
	}
	  %>
</div>
</body>
</html>